<template>
  <div id="top-playlists">
    <div class="title clearfix">
      {{ title }}
    </div>
      <!-- class="top-list-container"> -->
    <brief-playlists
      :playlists="playlists"
      @imgLoad="imgLoad"/>
  </div>
</template>

<script>
import { debounce } from 'utils'
import BriefPlaylists from 'components/content/briefplaylists/BriefPlaylists.vue'

export default {
  name: 'TopPlaylists',
  data () {
    return {
      imgLoadDebounce: null
    }
  },
  components: {
    BriefPlaylists
  },
  props: {
    title: {
      type: String,
      default () {
        return ''
      }
    },
    playlists: {
      type: Array,
      default () {
        return []
      }
    }
  },
  created () {
    this._getDeounce()
  },
  methods: {
    // 1. 获取防抖函数
    _getDeounce () {
      this.imgLoadDebounce = debounce(() => {
        this.$emit('imgLoad')
      })
    },
    // 2. 图片加载完成
    imgLoad () {
      this.imgLoadDebounce()
    }
  }
}
</script>

<style scoped lang="less">
#top-playlists {
  overflow: hidden;
  margin-bottom: 20px;
  .title {
    font-size: 20px;
    border-bottom: 1px solid #e1e1e2;
    padding-bottom: 10px;
    margin-bottom: 20px;
  }
  .top-list-container {
    overflow: hidden;
    // display: flex;
    // flex-wrap: wrap;
    // justify-content: space-around;
  }
}
</style>
